package db

import (
	"context"
	pb "gitee.com/airport_container/grpc_interface/gosdk/data_sync"
	"go.mongodb.org/mongo-driver/bson"
)

// GetCompanys 通過所有组板公司
func (s *MgoStore) GetBoardCompanys() ([]*pb.BoardCompanyModel, error) {
	collection := s.Client.Database(DbName).Collection("board_company")

	cur, err := collection.Find(context.Background(), bson.M{})
	if err != nil {
		return nil, err
	}
	defer cur.Close(context.Background())
	//序列化
	var models []*pb.BoardCompanyModel
	err = cur.All(context.Background(), &models)
	return models, err
}
